<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改大区会长预订单')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-agentorder-edit" th:object="${zsyhAgentOrder}">
            <input name="id" th:field="*{id}" type="hidden">
            <h4 class="form-header h4">大区会长预订单信息--【<span style="color: red">[[${zsyhAgentOrder.orderStateName}]]</span>】<span style="margin-left: 20%">合计金额：</span><span style="color: red">[[${zsyhAgentOrder.totalMoney}]]</span><span style="margin-left: 20%">厂家：</span><span style="color: red">[[${zsyhAgentOrder.factoryName}]]</span></h4>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <span class=" col-sm-4 control-label "><i class="fa fa-user"></i> 收货人:</span>
                        <!--<label class="col-sm-4 control-label fa fa-user">收货人：</label>-->
                        <div class="col-sm-4">
                            <p name="orderName" style="border-width: 0px;padding:6px 4px;"  class="form-control">[[*{orderName}]]</p>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <span class=" col-sm-4 control-label "><i class="fa fa-phone"></i> 收货电话:</span>
                        <!--<label class="col-sm-4 control-label fa fa-phone">收货电话：</label>-->
                        <div class="col-sm-4">
                            <p name="orderPhone" style="border-width: 0px;padding:6px 4px;"  class="form-control">[[*{orderPhone}]]</p>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                    <div class="form-group">
                        <span style="width: 18%" class=" col-sm-4 control-label "><i class="fa fa-send"></i> 详细地址:</span>
                        <!--<label style="width: 18%" class="col-sm-3 control-label fa fa-send">详细地址：</label>-->
                        <div class="col-sm-8">
                            <p name="orderAddress" style="border-width: 0px;padding:6px 4px;"  class="form-control">[[*{orderAddress}]]</p>
                        </div>
                   </div>
            </div>




            <!--<div class="form-group">
                <label class="col-sm-3 control-label">平台是否已确认 1是 0否：</label>
                <div class="col-sm-8">
                    <div class="radio-box" th:each="dict : ${@dict.getType('zsyh_yesno')}">
                        <input type="radio" th:id="${'isEnsurePlatform_' + dict.dictCode}" name="isEnsurePlatform" th:value="${dict.dictValue}" th:field="*{isEnsurePlatform}">
                        <label th:for="${'isEnsurePlatform_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>-->
            <h4 class="form-header h4">大区会长预订单详细信息</h4>
            <div class="row">
                <div class="col-sm-12">
                    <!--<button type="button" class="btn btn-white btn-sm" onclick="addColumn()"><i class="fa fa-plus"> 增加</i></button>
                    <button type="button" class="btn btn-white btn-sm" onclick="sub.delColumn()"><i class="fa fa-minus"> 删除</i></button>-->
                    <div class="col-sm-12 select-table table-striped" style="margin-top: 0px;">
                        <table id="bootstrap-table" data-page-size="10"
                               data-show-custom-view="true" data-custom-view="customViewFormatter"></table>
                    </div>
                </div>
            </div>
        </form>
    </div>

    <template id="profileTemplate">
        <div class="col-sm-3">
            <div class="contact-box" style="padding: 20px 20px 20px 5px">
                <a href="viewPlatformAttribute?id=%attributeId%">
                    <div class="m-t-xs font-bold">%attributeName%</div>
                    <div class="col-sm-4">
                        <div class="text-center">
                            <img alt="image" style="width: 65px;height: 65px" class="img-rounded m-t-xs img-rounded" src="%IMAGE%">
                        </div>
                    </div>
                    <div class="col-sm-8">
                        <!--<h3><strong>%attributeName%</strong></h3>-->
                        <p>单价：<i class="fa fa-jpy"></i> %orderPrice% </p>
                        <p><i >订货数量：</i> %orderCount% </p>
                        <p><i >发货数量：</i> %orderSellCount% </p>
                    </div>
                    <div class="clearfix"></div>
                </a>
            </div>
        </div>
    </template>

    <th:block th:include="include :: footer" />
    <th:block th:include="include :: bootstrap-table-custom-view-js" />
    <script th:inline="javascript">
        var prefix = ctx + "zsyh/agentorder";
        $("#form-agentorder-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-agentorder-edit').serialize());
            }
        }

        $(function() {
            var options = {
                data: [[${zsyhAgentOrder.zsyhAgentOrderRelList}]],
                pagination: false,
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                sidePagination: "client",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'index',
                    align: 'center',
                    title: "序号",
                    formatter: function (value, row, index) {
                    	var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
                    	return columnIndex + $.table.serialNumber(index);
                    }
                },
                {
                    field: 'partsId',
                    align: 'center',
                    title: '配件id',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='zsyhAgentOrderRelList[%s].partsId' value='%s'>", index, value);
                        return html;
                    }
				},
                {
                    field: 'attributeId',
                    align: 'center',
                    title: '型号id',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='zsyhAgentOrderRelList[%s].attributeId' value='%s'>", index, value);
                        return html;
                    }
				},
                {
                    field: 'orderCount',
                    align: 'center',
                    title: '预订数量',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='zsyhAgentOrderRelList[%s].orderCount' value='%s'>", index, value);
                        return html;
                    }
				},
                {
                    field: 'orderPrice',
                    align: 'center',
                    title: '单价',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='zsyhAgentOrderRelList[%s].orderPrice' value='%s'>", index, value);
                        return html;
                    }
				},
                {
                    field: 'createTime',
                    align: 'center',
                    title: '创建时间',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='zsyhAgentOrderRelList[%s].createTime' value='%s'>", index, value);
                        return html;
                    }
				},
                {
                    field: 'updateTime',
                    align: 'center',
                    title: '更新时间',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='zsyhAgentOrderRelList[%s].updateTime' value='%s'>", index, value);
                        return html;
                    }
				
                }]
            };
            $.table.init(options);
        });

        function customViewFormatter (data) {
            var template = $('#profileTemplate').html()
            var view = ''
            $.each(data, function (i, row) {
                view += template.replace('%IMAGE%', row.attributeLogo)
                    .replace('%attributeName%', row.attributeName)
                    .replace('%orderCount%', row.orderCount)
                    .replace('%orderPrice%', row.orderPrice)
                    .replace('%attributeId%', row.attributeId)
                    .replace('%orderSellCount%', row.orderSellCount);
            })
            return `<div class="row mx-0">${view}</div>`
        }
    </script>
</body>
</html>